Skip to content

feat(core): Support attribute matching in ignoreSpans#20512

Merged
nicohrubec merged 7 commits intodevelopfrom
nh/attributes-ignore-spans
Apr 27, 2026
Merged

feat(core): Support attribute matching in ignoreSpans#20512
nicohrubec merged 7 commits intodevelopfrom
nh/attributes-ignore-spans

Conversation

@nicohrubec
Copy link
Copy Markdown
Member

Extends ignoreSpans with a new optional attributes field per the ignoreSpans spec, letting users drop spans based on span attributes (in addition to name/description or op). String attribute values use pattern matching (substring / RegExp). Non-string values match by strict equality (arrays element-wise).

Closes #20360

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 25, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 26.09 kB +0.48% +123 B 🔺
@sentry/browser - with treeshaking flags 24.56 kB +0.52% +127 B 🔺
@sentry/browser (incl. Tracing) 44.04 kB +0.34% +149 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 45.7 kB +0.37% +167 B 🔺
@sentry/browser (incl. Tracing, Profiling) 48.98 kB +0.3% +142 B 🔺
@sentry/browser (incl. Tracing, Replay) 83.24 kB +0.19% +154 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 72.73 kB +0.19% +135 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 87.92 kB +0.18% +151 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 100.54 kB +0.16% +159 B 🔺
@sentry/browser (incl. Feedback) 43.32 kB +0.32% +137 B 🔺
@sentry/browser (incl. sendFeedback) 30.89 kB +0.41% +124 B 🔺
@sentry/browser (incl. FeedbackAsync) 36.06 kB +0.38% +134 B 🔺
@sentry/browser (incl. Metrics) 27.38 kB +0.48% +130 B 🔺
@sentry/browser (incl. Logs) 27.52 kB +0.53% +143 B 🔺
@sentry/browser (incl. Metrics & Logs) 28.21 kB +0.48% +132 B 🔺
@sentry/react 27.83 kB +0.42% +115 B 🔺
@sentry/react (incl. Tracing) 46.27 kB +0.31% +139 B 🔺
@sentry/vue 30.95 kB +0.45% +138 B 🔺
@sentry/vue (incl. Tracing) 45.87 kB +0.35% +158 B 🔺
@sentry/svelte 26.1 kB +0.47% +122 B 🔺
CDN Bundle 28.76 kB +0.38% +107 B 🔺
CDN Bundle (incl. Tracing) 46.27 kB +0.33% +148 B 🔺
CDN Bundle (incl. Logs, Metrics) 30.16 kB +0.43% +128 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 47.32 kB +0.34% +157 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 69.12 kB +0.19% +131 B 🔺
CDN Bundle (incl. Tracing, Replay) 83.31 kB +0.16% +126 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 84.34 kB +0.15% +126 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 89.14 kB +0.16% +135 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 90.19 kB +0.15% +135 B 🔺
CDN Bundle - uncompressed 84.36 kB +0.54% +450 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 138.42 kB +0.44% +596 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 88.51 kB +0.52% +450 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 141.83 kB +0.43% +596 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 212.08 kB +0.22% +450 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 255.86 kB +0.24% +596 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 259.25 kB +0.24% +596 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 269.56 kB +0.23% +596 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 272.94 kB +0.22% +596 B 🔺
@sentry/nextjs (client) 48.77 kB +0.3% +143 B 🔺
@sentry/sveltekit (client) 44.49 kB +0.36% +158 B 🔺
@sentry/node-core 58.47 kB +0.25% +145 B 🔺
@sentry/node 169.53 kB +0.1% +158 B 🔺
@sentry/node - without tracing 97.26 kB +0.14% +134 B 🔺
@sentry/aws-serverless 114.01 kB +0.14% +159 B 🔺
@sentry/cloudflare (withSentry) - minified 162.03 kB +0.36% +573 B 🔺
@sentry/cloudflare (withSentry) 408.94 kB +0.27% +1.06 kB 🔺

View base workflow run

nicohrubec and others added 3 commits April 25, 2026 10:37
@nicohrubec nicohrubec marked this pull request as ready for review April 27, 2026 08:34
@nicohrubec nicohrubec requested review from chargome and mydea April 27, 2026 08:35
Comment thread packages/core/src/utils/should-ignore-span.ts
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aad1cb6. Configure here.

Comment thread packages/core/src/utils/should-ignore-span.ts
Comment thread .size-limit.js
import: createImport('init'),
gzip: true,
limit: '26 KB',
limit: '27 KB',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundle size increased across browser packages

Low Severity

Multiple browser bundle size limits were raised by ~1 KB gzipped (e.g., @sentry/browser 26→27 KB, tracing 44→45 KB, @sentry/svelte 26→27 KB, plus several CDN bundles). Per project rules, large bundle size increases in browser packages need to be flagged even when they may be unavoidable for a new feature.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit aad1cb6. Configure here.

Comment on lines +38 to +42
const attrsMatch = pattern.attributes
? Object.entries(pattern.attributes).every(([key, valuePattern]) =>
_matchesAttributeValue(span.attributes?.[key], valuePattern),
)
: true;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The function shouldIgnoreSpan inconsistently handles an empty attributes: {} filter. It's ignored when alone but causes a match when combined with op or name due to vacuous truth.
Severity: LOW

Suggested Fix

To ensure consistent behavior, modify the logic to treat an empty attributes object as a non-match, regardless of whether op or name are also present. One approach is to adjust the attrsMatch check to explicitly return false if pattern.attributes is an empty object. This would align the behavior with the author's apparent intent, as demonstrated in the existing test cases.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/core/src/utils/should-ignore-span.ts#L38-L42

Potential issue: There is an inconsistency in how `shouldIgnoreSpan` handles an empty
`attributes: {}` filter. When a filter pattern consists solely of `{ attributes: {} }`,
a guard condition correctly prevents it from matching any spans. However, if the pattern
is combined with an `op` or `name` (e.g., `{ op: 'http.server', attributes: {} }`), this
guard is bypassed. The logic then evaluates `Object.entries({}).every(...)` for the
attributes, which resolves to `true` due to vacuous truth. This causes the span to be
matched based on `op` or `name` alone, which is likely unintentional as a test
explicitly asserts that an empty attributes object should not cause a match.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is fine

Copy link
Copy Markdown
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

@nicohrubec nicohrubec merged commit 15a6a8b into develop Apr 27, 2026
256 checks passed
@nicohrubec nicohrubec deleted the nh/attributes-ignore-spans branch April 27, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adjust ignoreSpans to allow filtering on arbitrary attributes

2 participants